<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>抢课系统</title>
	<link rel="stylesheet" href="Css/bootstrap.min.css">
	<link rel="stylesheet" href="Css/login.css">
</head>
<body>
	<div class="container">
	<div class="row clearfix" id="header">
		<div class="col-md-11 column">
			<h3 class="text-center">
				添加新任务
			</h3>
		</div>
		<div class="col-md-1 column">
			<a href="/scucource/tasks.html">任务列表</a>
		</div>
	</div>
	<div class="row clearfix">
		<div class="col-md-2 column">
		</div>
		<div class="col-md-6 column">
			<form class="form-horizontal" role="form" enctype="application/json" id="add-form">
				<div class="form-group">
					 <label for="coursenumber" class="col-sm-2 control-label">课程号</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" id="coursenumber" name="coursenumber" />
					</div>
				</div>
				<div class="form-group">
					 <label for="sycnumber" class="col-sm-2 control-label">课序号</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" id="sycnumber" name="sycnumber" />
					</div>
				</div>
				
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						 <button type="button" class="btn btn-default" id="btn-add">添加</button>
					</div>
				</div>
			</form>
		</div>
		<div class="col-md-4 column">
		</div>
	</div>
</div>

<script src="Js/jquery.min.js"></script>
	<script src="Js/bootstrap.min.js"></script>
	<script src="Js/jquery.json.min.js"></script>

	<script>
	$(document).ready(function() {
		$.ajaxSetup({ contentType: 'application/json' }); 
		$('#btn-add').click(function() {
			/* Act on the event */
			$coursenumber	=	$('#coursenumber').val();
			$sycnumber	=	$('#sycnumber').val();
			if(!$coursenumber){
				alert('请输入课程号！');
				return;
			}
			if(!$sycnumber){
				alert('请输入课序号！');
				return;
			}
			$param = {"coursenumber":$coursenumber,"sycnumber":$sycnumber};
			$param1 = $.toJSON($param);
			$action = "/scucource/scucorse/core/task";
			console.log('1');
			$.post($action, $param1, function(data) {
				/*optional stuff to do after success */
				if(data.status == 3){
					alert('您还未登录！确定后返回登录');
					window.location.href = "/scucource/login.html";
				}else if(data.status == 0){
					alert('添加成功，确定后前往任务列表！');
					window.location.href = "/scucource/tasks.html";					
				}
				//错误处理
				//成功->跳转 
			});
		});
	});
	</script>
</body>
</html>